/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DatabaseConnection;

import Entities.Passenger;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author serhat
 */
public class PassengerDbConnection extends Connector{
    
    public PassengerDbConnection() throws ClassNotFoundException, 
    SQLException, InstantiationException, IllegalAccessException {
        
    }
    
    private String buildInsertQuery(Passenger passenger){
        String query = String.format("INSERT INTO Yolcu VALUES("
                + "'%d', '%s', '%s')", passenger.getTcKimlik(), passenger.getName(), passenger.getLastName());
        return query;
    }
    
    public int insert(Passenger passenger){
        try {
            String query = buildInsertQuery(passenger);
            int key = executeUpdateAndReturnKey(query);
            return key;
        } catch (SQLException ex) {
            Logger.getLogger(PassengerDbConnection.class.getName()).log(Level.SEVERE, null, ex);
            return -1;
        }
        
    }
}
